Repository navigation
fix(libSceNet): report EAGAIN when a stream send or receive times out on Windows - #4758
Closed
EagleBearerYS wants to merge 2 commits into
Closed
EagleBearerYS wants to merge 2 commits into
EagleBearerYS wants to merge 2 commits into
Conversation
6 tasks done
Contributor
|
Windows test: head AI-assisted (Claude Code). |
10 tasks done
…lTimeouts boykopovar#4924 adds a test after CheckKernelTimeouts and its call after CheckKernelTimeouts(), so placing the new check there made the two pull requests conflict.
Collaborator
|
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
SO_RCVTIMEOandSO_SNDTIMEOon a libSceNet socket are set as the host socket's timeouts. On Windows a blocking receive or send on a stream socket that times out then fails withETIMEDOUT(0x8041013c), where FreeBSD 11.4 returnsEAGAIN:sbwait()sleeps for the buffer'ssb_timeoand returnsEWOULDBLOCKwhen it runs out;soreceive_generic()andsosend_generic()return that error;kern_sendit()returns the partial count instead when part of the data was sent.Winsock reports its own timeout as
WSAETIMEDOUTwith no partial count, and documents that the connection is then in an indeterminate state (SOL_SOCKET options). #4092 fixed the datagram case, where the host timeout is safe. The stream case was left in TechnicalDebt for this reason.On Windows, a blocking
sceNetRecv,sceNetRecvfrom,sceNetRecvmsg,sceNetSendorsceNetSendto(and sosceNetSendmsg) on a stream socket with a timeout now waits for the socket withWSAPollfor that timeout first. It fails withEAGAINwhen the wait ends, so the host timeout does not fire and the connection stays usable. A zero-length transfer does not wait, as insoreceive_generic().A socket the host reports as unconnected (
getpeernamefails) does not wait either, becauseWSAPollreports no event for it until the timeout. This covers a never-connected socket and a listening one, so their receive still fails at once withENOTCONN.The host option stays set for one case: a receive whose data another thread takes between the wait and the receive. That timeout now also maps to
EAGAINfor stream sockets.Linux and macOS are unchanged; their host timeouts already behave as FreeBSD's. The TechnicalDebt entry is rewritten. What remains is a send that starts while the socket is writable and still blocks past the timeout: it fails with
ETIMEDOUT, where FreeBSD returns the partial count. No title is claimed.The dependencies on #4669 and #4673 are only about merge order. They change the lines next to this change: the libSceNet TechnicalDebt entry above it, and
sceNetSend's send call. This branch follows them once they merge.Tested
Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release,
-DBUILD_TESTING=ON, onmainat c952c2b:CheckStreamTimeoutsinguest_sce_net, on a connected loopback TCP pair:SO_RCVTIMEO,sceNetRecv(without and withMSG_PEEK),sceNetRecvfromandsceNetRecvmsgfail withEAGAINafter at least 40 ms. Data sent afterwards still arrives.sceNetRecvon a never-connected socket and on the listening socket, both with the same timeout, fails withENOTCONN.SO_SNDBUFand a 50 msSO_SNDTIMEO, 64 KiB sends to a peer that does not read succeed until one fails withEAGAINafter at least 40 ms.main'sExport.cpp, the test aborts at the first timed-outsceNetRecv, which fails with0x8041013c(ETIMEDOUT) after 50 ms.EAGAIN, but the send that fills the peer fails withETIMEDOUTafter 49 ms, 393216 bytes in.getpeernamecheck, the receive on the unconnected socket waits and fails withEAGAIN.guest_sce_netpasses 20 runs in a row.guest_sce_net,guest_memory_pool_stats,guest_resolver, theguest_datagram_*andguest_socket_host_write_*tests, and the tests registered incore/libs/prx/libc/CMakeLists.txtandcore/libs/prx/libkernel/CMakeLists.txtthat build on Windows.tools/check_conventions.py --base origin/mainpasses.-DANYPS5_ENABLE_SPIRV_TOOLS=ON), on the same commit.guest_sce_net, includingCheckStreamTimeouts, passes 20 runs in a row. The code change does not apply there; the test checks that Linux's own timeouts already giveEAGAIN, the sent count andENOTCONN.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)